home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rwvector.lha / RWVector2.1 / src / mathpack / sscal.f < prev    next >
Text File  |  1989-08-17  |  3KB  |  76 lines

  1. c   imsl routine name   - vbla=sscal                                    vbsm0010
  2. c
  3. c-----------------------------------------------------------------------
  4. c
  5. c   computer            - vax/single
  6. c
  7. c   latest revision     - january 1, 1978
  8. c
  9. c   purpose             - compute a single precision constant
  10. c                           times a single precision vector
  11. c
  12. c   usage               - call sscal (n,sa,sx,incx)
  13. c
  14. c   arguments    n      - length of vector x. (input)
  15. c                sa     - real scalar. (input)
  16. c                sx     - real vector of length n*incx. (input/output)
  17. c                           sscal replaces x(i) with sa*x(i) for
  18. c                           i=1,...,n.
  19. c                           x(i) refers to a specific element of sx.
  20. c                           see incx argument description.
  21. c                incx   - displacement between elements of sx. (input)
  22. c                           x(i) is defined to be sx(1+(i-1)*incx).
  23. c                           incx must be greater than zero.
  24. c
  25. c   precision/hardware  - single/all
  26. c
  27. c   reqd. imsl routines - none required
  28. c
  29. c   notation            - information on special notation and
  30. c                           conventions is available in the manual
  31. c                           introduction or through imsl routine uhelp
  32. c
  33. c   copyright           - 1978 by imsl, inc. all rights reserved.
  34. c
  35. c   warranty            - imsl warrants only that imsl testing has been
  36. c                           applied to this code. no other warranty,
  37. c                           expressed or implied, is applicable.
  38. c
  39. c-----------------------------------------------------------------------
  40. c
  41.       subroutine sscal  (n,sa,sx,incx)
  42. c
  43. c                                  specifications for arguments
  44.       integer            incx,n
  45.       real               sa,sx(1)
  46. c                                  specifications for local variables
  47.       integer            i,m,mp1,ns
  48. c                                  first executable statement
  49.       if (n.le.0) return
  50.       if (incx.eq.1) go to 10
  51. c                                  code for increments not equal to 1.
  52.       ns = n*incx
  53.       do 5 i=1,ns,incx
  54.          sx(i) = sa*sx(i)
  55.     5 continue
  56.       return
  57. c                                  code for increments equal to 1.
  58. c                                    clean-up loop so remaining vector
  59. c                                    length is a multiple of 5.
  60.    10 m = n-(n/5)*5
  61.       if (m.eq.0) go to 20
  62.       do 15 i=1,m
  63.          sx(i) = sa*sx(i)
  64.    15 continue
  65.       if (n.lt.5) return
  66.    20 mp1 = m+1
  67.       do 25 i=mp1,n,5
  68.          sx(i) = sa*sx(i)
  69.          sx(i+1) = sa*sx(i+1)
  70.          sx(i+2) = sa*sx(i+2)
  71.          sx(i+3) = sa*sx(i+3)
  72.          sx(i+4) = sa*sx(i+4)
  73.    25 continue
  74.       return
  75.       end
  76.